package role

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/model"
	"parking-lot-go-admin/model/admin"

	"github.com/gin-gonic/gin"
)

func RoleMy(c *gin.Context) {

	requestDataStruct := struct {
		AdminId int `json:"admin_id"`
	}{}
	c.ShouldBindJSON(&requestDataStruct)

	//查询信息
	var adminWithGroupStruct admin.AdminWithGroupStruct
	var adminWithGroupData []admin.AdminWithGroupStruct

	model.GetModelData(
		model.Db,
		adminWithGroupStruct.TableName(),
		&adminWithGroupData,
		model.QueryOptions{
			Conditions: map[string]interface{}{
				"admin_id": requestDataStruct.AdminId,
			},
			OrderBy: "id desc",
			Debug:   true,
		},
	)

	returnInt := []int{}
	for _, v := range adminWithGroupData {
		returnInt = append(returnInt, v.AdminGroupId)
	}

	controller.Success(c, returnInt)
}
